
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QFrame>
#include <QMainWindow>
#include <QTimer>
#include <QLabel>

#include "datapanel.h"
#include "controlpanel.h"
#include "qcustomplot.h"
#include <QPair>
#include <QColor>
#include "cfgcom.h"
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow

{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

protected:
    void showEvent(QShowEvent * event) override;

public Q_SLOTS:
    // 时间显示
    void timeShow();

public:
    void uiInit();
    void dataPanelInit();
    void ctlPanelInit();
    void setShadow(QString background_color,QString shadow_color,QWidget *widget,bool bac_none = false, qint64 radius = 10);

    void dataManageHandle();

    void tiemPlugsInit();

    void linePanelInit();

    void addLine(QCustomPlot *costomPlot,QVector<QPair<QString,QColor>> lines);

    void setLine1Panel();
    void setLine2Panel();

    void setPanelData(QCustomPlot *costomPlot,double data_0,double data_1);

private slots:
    void on_btn_set_clicked();

    void on_comboBox_auto_currentTextChanged(const QString &arg1);


    void on_comboBox_model_currentTextChanged(const QString &arg1);

Q_SIGNALS:
    void sendData(QString data);

public Q_SLOTS:
    void receiveData(QByteArray data);

private:
    Ui::MainWindow *ui;
    QSharedPointer<QTimer> timer;

    DataPanel * temp;
    DataPanel * humi;
    DataPanel * light;
    DataPanel * soil;

    ControlPanel * temp_ctl;
    ControlPanel * humi_ctl;
    ControlPanel * light_ctl;
    ControlPanel * soil_ctl;

    QCustomPlot * m_line1;
    QCustomPlot * m_line2;

    CfgCom * cfgCom;
};

#endif // MAINWINDOW_H
